<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>编辑</title>
		<link rel="stylesheet" type="text/css" href="../../plugins/layui/css/layui.css" />
		<link href="../../kitAdmin/css/app.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css" href="../../plugins/select2/dist/css/select2.min.css" />
	</head>

	<body>
		<div class='kit-table'>
			<div style='margin:10px'>

				<ul id="lhul">

				</ul>
			</div>
		</div>
		<script src="../../common/js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../static/js/base.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../plugins/jsviews/jsviews.js" type="text/javascript"></script>
		<script src="../../plugins/select2/dist/js/select2.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../plugins/laydate5.0.9/laydate.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../plugins/layui/layui.js"></script>
		<script type="text/javascript">
			var id = getQueryVariable('id');
			var type = getQueryVariable('type');
			jQuery(document).ready(function() {
				init();
			});
			var callback_save = function() {
				return $('.layui-form').serialize();
			}
			var init = function() {
				$.ajax({
						   url: baseUrl + '/curriculumSchedules/video/' + id + "?type=" + type,
					type: 'get',
					async: false,
					success: function(datas) {
						var htm = "";
						var data = datas.data;
						for(var i = 0; i < data.length; i++) {
							// htm += '<li href="' + data[i].url + '" >' + data[i].dateTime + '</>';
							htm += '<li><a href="' + data[i].url + '">' + data[i].dateTime + '</a></>';
						}
						$('#lhul').append(htm);
					},
					error: function() {
						parent.layer.alert('加载课程信息失败！');
					}
				});
			}


			layui.use(['form', 'laydate'], function() {
				var form = layui.form;
				//监听变化
				form.on('select(material)', function(data) {
					$.ajax({
						url:baseUrl+ '/lessonLevels?lessonId=' + data.value,
						type: 'get',
						async: false,
						success: function(data) {
							var htm = "";
							data = data.rows;
							for(var i = 0; i < data.length; i++) {
								htm += '<option value="' + data[i].levelId + '">' + data[i].text + '</option>';
								// htm += '<option value="' + data[i].levelId + '">年级：' + data[i].levelName + '</option>';
							}

                            $("#materialLevel").find("option:selected").text("");
                            $("#materialLevel").empty();

							$('#materialLevel').append(htm);
							form.render('select', 'materialLevel');
							form.render('select');
						},
						error: function() {
							parent.layer.alert('加载教师信息失败！');
						}
					});
				});
				//监听提交
				form.on('submit(formDemo)', function(data) {
					layer.msg(JSON.stringify(data.field));
					return false;
				});
			});

			function renderForm(data) {
				$.ajax({
					url:baseUrl+ '/lessonLevels?lessonId=' + data.material,
					type: 'get',
					async: false,
					success: function(data) {
						var htm = "";
						data = data.rows;
						for(var i = 0; i < data.length; i++) {
							// htm += '<option value="' + data[i].levelId + '">年级：' + data[i].levelName + '</option>';
							htm += '<option value="' + data[i].levelId + '">' + data[i].text + '</option>';
						}
						$('#materialLevel').append(htm);
						
					},
					error: function() {
						parent.layer.alert('加载教师信息失败！');
					}
				});
				//-------------------------------------
				$('#materialLevel').val(data.materialLevel);
				layui.use('form', function() {
					var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
					form.render();
				});
			}
		</script>
	</body>

</html>